package com.woniuxy.dr_mall.controller;


import com.woniuxy.dr_mall.entity.DrMenu;
import com.woniuxy.dr_mall.entity.MyResponseEntity;
import com.woniuxy.dr_mall.service.IDrMenuService;
import com.woniuxy.dr_mall.utils.Audience;
import com.woniuxy.dr_mall.utils.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张哲轩
 * @since 2021-08-11
 */
@RestController
@RequestMapping("/dr_mall/drMenu")
public class DrMenuController {
    @Autowired
    private IDrMenuService drMenuService;

    @Autowired
    private Audience audience;

    @GetMapping("list")
    public MyResponseEntity<List<DrMenu>> getMenusByDrManager(@RequestHeader("token") String jwt){
        int id = JwtUtil.getId(jwt, audience.getBase64Secret());
        return new MyResponseEntity<>(drMenuService.getByDrManagerId(id));
    }
}

